package com.ssi.core.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;

/**
 * 该类用于加载平台运行时配置信息
 * @创建时间 Jan 8, 2011 4:01:31 PM
 * @创建人： Farley
 * @邮箱：kfy0521@163.com
 */
public class FrameworkConfig {
	protected final Log logger = LogFactory.getLog(FrameworkConfig.class);
	private Resource location;
 
	/**
	 * 获取运行时配置信息，对应的是/WEB-INF/config/sis-config.properties文件
	 * @return 返回sis-config.properties文件的Properties对象
	 */
	public Properties getConfig() {
		Properties props = null;

		try {
        	props = new Properties();
        	logger.info("loading properties file :" + location.getFilename());
        	InputStream is = location.getInputStream();
			props.load( is );
			is.close();
		} catch (IOException e) {
			logger.error("Unable to load " +  location.getFilename(), e);
			return null;
			
		}
		return props;
	}
	

	public Resource getLocation() {
		return location;
	}

	public void setLocation(Resource location) {
		this.location = location;
	}
}
